<template>
  <div class="searchdata">
    <van-dropdown-menu>
      <van-dropdown-item v-model="value1" :options="option1" />
      <van-dropdown-item
        v-model="value2"
        :options="option2"
        @change="onChange1"
      />
      <van-dropdown-item
        v-model="value3"
        :options="option3"
      />
    </van-dropdown-menu>
    <!-- <searchGoodslist2 /> -->
    <ul class="searchgoodslist">
      <li v-for="v in getsearchdata" :key="v.id" @click="tiao(v.id)">
        <img :src="v.list_pic_url" alt="" />
        <h5>{{ v.name }}</h5>
        <p>{{ v.retail_price | fil }}</p>
      </li>
    </ul>
    <!-- <goodsDetail></goodsDetail> -->
  </div>
</template>

<script>
import { GetSearchList } from "@/request/api";
import goodsDetail from "@/components/buy/goodsDetail";
export default {
  props: ["value"],
  name: "H559Searchinfo",

  components: {
    goodsDetail,
  },

  directives: {},

  data() {
    return {
      value1: 0,
      value2: "a",
      value3: "A",
      option1: [
        { text: "综合", value: 0 },
        { text: "新款商品", value: 1 },
        { text: "活动商品", value: 2 },
      ],
      option2: [
        { text: "价格", value: "a" },
        { text: "价格从高到低", value: "desc" },
        { text: "价格从低到高", value: "asc" },
      ],
      option3: [
        { text: "分类", value: "A" },
        { text: "全部", value: "1" },
        { text: "居家", value: "0" },
      ],
      id: "",
      retail_price: [],
      getsearchdata: "",
    };
  },

  filters: {
    fil(v) {
      let string = v.toFixed(2);
      let str = "￥ " + string + "元";
      return str;
    },
  },
  mounted() {},

  methods: {
    onChange1(v) {
      console.log(v);
      GetSearchList({ 
        keyword: this.value,
        size: 20, 
        page: 1,
        order:v,
        sort:"price",
        }).then((res) => {
        this.getsearchdata = res.data.data;
      });
    },

    tiao(v) {
      this.id = v;
      // console.log(this.id);
      this.$router.push({
        path: "/goodsDetail",
        query: {
          id: this.id,
        },
      });
    },
  },
  created() {
    GetSearchList({ keyword: this.value, size: 20, page: 1 }).then((res) => {
      // console.log(res);
      this.getsearchdata = res.data.data;
      // console.log(this.getsearchdata);
    });
  },
};
</script>

<style lang="less" scoped>
</style>